<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<script type="text/javascript" src="./lib/jquery-3.3.1.min.js"></script>
	<script type="text/javascript" src="./lib/prism.js"></script>
	<link rel="stylesheet" type="text/css" href="./lib/prism.css">
	<script type="text/javascript">
		function moveEnd(obj,len){
            obj.focus(); 
            var sel = obj.createTextRange(); 
            sel.moveStart('character',len); //设置开头的位置
            sel.collapse(); 
            sel.select(); 
        }
	</script>
</head>
<body>
	<pre>
		<code class="language-html" id="codeMain" contenteditable="true" oninput="var last=window.getSelection().focusOffset;console.log(last);var lastNode=window.getSelection().focusNode;Prism.highlightElement(document.getElementById('codeMain'));moveEnd(this,last)">&lt;sfzhgsj duurbu="fgfg"&gt;dhvfdjgdjfg&lt;/sfzhgsj&gt;</code>
	</pre>
</body>
</html>